package sample.sub1.section09

object FileMatcher {
	private def filesHere = (new java.io.File(".")).listFiles;
	private def fileMatching(matcher: String => Boolean) = {
		for (file <- filesHere; if matcher(file.getName))
			yield file
		
	}
	
	def filesEnding(query: String) = fileMatching(_.endsWith(query));
	def filesContains(query: String) = fileMatching(_.contains(query));
	def filesRegex(query: String) = fileMatching(_.matches(query));
}